package com.modular.event.opt;

import cn.hutool.core.date.DateUtil;
import cn.hutool.db.Entity;
import com.modular.event.bean.AlarmRecordsDO;
import com.c.opt.ComOpt;

/**
 * @author: liuwenju
 * @date: 2023/6/5 13:28
 * @version: 1.0
 */
public class OptAlarmRecords extends ComOpt<AlarmRecordsDO> {

    public OptAlarmRecords() {
        super("alarm_records");
    }

    /**
     * 更新为已读状态
     * @param id
     */
    public void updateRead(String id) {
        AlarmRecordsDO beanById = getBeanById(id);
        if ("2".equals(beanById.getIsRead())) {
            beanById.setIsRead("2");
            syncBean(beanById);
        }
    }

    /**
     * 更新事件状态
     * @param alarmRecordsId
     */
    public void updateFinal(String alarmRecordsId) {
        AlarmRecordsDO beanById = getBeanById(alarmRecordsId);
        beanById.setStatus("2");
        beanById.setIsRead("2");
        beanById.setHandlerTime(DateUtil.now());
        syncBean(beanById);
    }
}
